<?php
/**
 * function remove_wp_headlinks()
 * 
 * Remove unnecessary headlinks that fail validation in wp_head hook
 */
function echotheme_remove_headlinks()
{
	remove_action('wp_head', 'index_rel_link');
	remove_action('wp_head', 'rsd_link');
	remove_action('wp_head', 'wlwmanifest_link');
	remove_action('wp_head', 'wp_generator');
}

add_action('init', 'echotheme_remove_headlinks');

/**
 * generates the tile text
 */
function echotheme_title()
{
	/*
	 * Print the <title> tag based on what is being viewed.
	 */
	global $page, $paged;
	
	$separator = ' | ';

	wp_title( $separator, true, 'right' );

	// Add the blog name.
	bloginfo( 'name' );

	// Add the blog description for the home/front page.
	$site_description = get_bloginfo( 'description', 'display' );
	if ( $site_description && ( is_home() || is_front_page() ) )
		echo $separator . $site_description;

	// Add a page number if necessary:
	if ( $paged >= 2 || $page >= 2 )
		echo $separator . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );
}

/**
 * Use my jQuery 
 */
function echotheme_jquery() {
	wp_deregister_script('jquery');
	wp_register_script('jquery', get_bloginfo('template_url') . '/js/jquery-1.7.1.min.js', '1.7.1');
	wp_enqueue_script('jquery');
	
	wp_register_script('jquery-easing', get_bloginfo('template_url') . '/js/jquery.easing.js', array('jquery'), '1.3');
}
add_action('wp_enqueue_scripts', 'echotheme_jquery');

/**
 * general javascript
 */
function echotheme_general_javascript()
{
	wp_enqueue_script('general', get_bloginfo('template_url') . '/js/general.js', array('jquery'));
	wp_enqueue_script('superfish');
	// wp_enqueue_script('echo-menu', ABSURL . '/js/echoDropDownMenu.js', array('jquery'));
}

add_action('wp_enqueue_scripts', 'echotheme_general_javascript');

/**
 * Function for linking to custom css files
 */
function echotheme_general_css()
{ 
	global $echotheme_options;
	if (isset($echotheme_options)) {
		wp_enqueue_style('custom-style');
	}
	
	// enqueue all the necessary theme styles
	wp_enqueue_style('base');
	wp_enqueue_style('skeleton');
    wp_enqueue_style('layout');
	wp_enqueue_style('theme');
	wp_enqueue_style('style');
}

add_action('wp_print_styles', 'echotheme_general_css');

/**
 * Creates action hook to be called directly before wp_head action
 */
function echotheme_pre_wp_head()
{ 
	// run the hook to add custom stuff at end of head
	do_action('echotheme_pre_wp_head');
}

/**
 * Creates action hook to be called directly before closing the head
 */
function echotheme_post_wp_head()
{ 
	// run the hook to add custom stuff at end of head
	do_action('echotheme_post_wp_head');
}

/**
 * Include scripts and styles based on different requirements
 */
function echotheme_specific_links()
{
	if (is_home() || is_front_page()) {
		// add_action('wp_enqueue_scripts', 'echotheme_homepage_links');
		// echotheme_load_flexslider();
	}

	if (defined('SHADOWBOX')) {
		// add_action('wp_enqueue_scripts', 'echotheme_load_shadowbox');
		echotheme_load_shadowbox();
	}

	if (defined('SLIDESHOW')) {
	    // add_action('wp_enqueue_scripts', 'echotheme_slideshow_links');
		echotheme_slideshow_links();
	}
}

add_action('echotheme_pre_wp_head', 'echotheme_specific_links');

/**
 * Function/hook for adding Shadowbox to a page
 */
function echotheme_load_shadowbox()
{
	wp_enqueue_style('shadowbox', get_bloginfo('template_url') . '/inc/scripts/shadowbox/shadowbox.css');
	wp_enqueue_script('shadowbox', get_bloginfo('template_url') . '/inc/scripts/shadowbox/shadowbox.js', array('jquery'));	
}

/**
 * Function to load isotope
 */
function echotheme_load_isotope()
{
	// isotope
	wp_enqueue_script('isotope', get_bloginfo('template_url') . '/inc/scripts/isotope/jquery.isotope.min.js', array('jquery'));
	wp_enqueue_style('isotope', get_bloginfo('template_url') . '/inc/scripts/isotope/style.css', false, '', 'screen');
}
/**
 * Function/hook for adding Slideshow to a page
 */
function echotheme_load_flexslider()
{
	wp_enqueue_script('flexslider', get_bloginfo('template_url') . '/inc/scripts/flexslider/jquery.flexslider-min.js', array('jquery-easing'));
	wp_enqueue_style('flexslider', get_bloginfo('template_url') . '/inc/scripts/flexslider/flexslider.css');
}
add_action('echotheme_pre_wp_head', 'echotheme_load_flexslider');

function echotheme_load_jqueryCycle()
{
	wp_enqueue_script('jqueryCycle', get_bloginfo('template_url') . '/inc/scripts/cycle/jquery.cycle.all.js', array('jquery'));
}
// add_action('echotheme_pre_wp_head', 'echotheme_load_jqueryCycle');
?>